<style lang="scss" scoped>
	@import "../../utils/base.scss";
</style>
<template>
	<div class="quest_content" style="overflow:auto;">
		<!-- <div class="qheader" style="border-bottom: 1px solid rgb(210,210,210);">
            <p>基本信息</p>
        </div> -->
		<div class="gcontent">
			<Form ref="childrenInfo" :model="childrenInfo" :rules="childrenValidate" :label-width="labelWidth" label-position="left"
			 class="form form_left">
				<Row v-if="reqId != '' && reqId != null">
					<Col span="8">
					<FormItem label="工单ID:">
						<Input v-model="reqId" :readonly="true" />
					</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="8">
					<FormItem label="工单标题:" prop="reqSubject">
						<Input v-model="childrenInfo.reqSubject" :readonly="ifedit" />
					</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="22" style="width:96.666667%">
					<FormItem label="申请描述:" prop="reqDes">
						<Input v-model="childrenInfo.reqDes" :readonly="ifedit" placeholder="请描述申请原因及用途" type="textarea" :autosize="{minRows: 4,maxRows: 6}" />
					</FormItem>
					</Col>
				</Row>
				<!-- 附件 -->
				<!-- <template>
					<div class="qheader" :style="{borderBottom: '1px solid rgb(210,210,210)',}">
						<p>附件</p>
					</div>
					<component ref="file" :is="'file'" :ifedit="ifedit" :filesList="filesList" v-model="childrenInfo.files"></component>
				</template> -->
			</Form>
		</div>
	</div>
</template>
<script>
	import ajax from "../../ajax_util"
	import Axios from 'axios'
	import file from './settledin/file'

	export default {
		name: "children",
		components: {
			file
		},
		data() {
			return {
				showFileMould: false,
				httpHeader: {
					Authorization: this.$store.state.token
				},
				fileUrl: this.CONFIG.file_url,
				labelWidth: 140,
				childrenValidate: {
					reqSubject: [{
						required: true,
						type: 'string',
						message: '请填写需求主题',
						trigger: 'blur'
					}, {
						type: 'string',
						max: 50,
						message: '最多填写50个字符',
						trigger: 'blur'
					}],
					reqDes: [{
						required: true,
						type: 'string',
						message: '请填写需求描述',
						trigger: 'change'
					}, ],
				},
				childrenInfo: {
					reqSubject: "", //需求主题
					reqDes: "", //需求描述
					files: []
				}
			}
		},
		mounted: function() {
			console.log("this.reqId,this.draftsId---------->", this.reqId, this.draftsId)
			if (this.reqId != null) {
				this.reqId = this.reqId
				this.getApplyInfo(); //获取表单详情
			} else if (this.draftsId != null) {
				console.log("获取草稿---------->")
				this.getDrafts()
			}
		},
		methods: {
			getDrafts() {
				var url = this.CONFIG.base_url_test + "/draft/content/" + this.draftsId
				var that = this;
				ajax.get({
					url: url,
					that: that,
					params: null,
					success: function(data) {
						if (data.req.reqSubject === undefined) {
							that.childrenInfo.reqSubject = data.req.overview.reqSubject
							that.childrenInfo.reqDes = data.req.overview.reqDes
							that.childrenInfo.files = data.req.files
						} else {
							that.childrenInfo = data.req
						}
					}
				})
			},
			getApplyInfo() {
				var data = this.processInfo
				console.log("获取 ----> ", data.content)
				this.childrenInfo.reqSubject = data.reqSubject
				this.childrenInfo.reqDes = data.reqDes
				if (data.files != undefined && data.files != null) {
					this.childrenInfo.files = data.files
				}
			},
			getInfo() {
				var publicInfo = this.utils.setPublicInfoInfo(this.childrenInfo.reqSubject, 0, 0, this.childrenInfo.reqDes)
				this.childrenInfo.puslicInfo = publicInfo
				return this.childrenInfo
			},
			validate() {
				var isSubmit = false
				this.$refs["childrenInfo"].validate((valid) => {
					if (valid) {
						isSubmit = true
					} else {
						this.$Message.error('请填写必填项');
					}
				})
				return isSubmit
			},
			// 获取处理时需要提交的参数
			getHandleParams(handleInfo) {
				handleInfo.reqSubject = this.childrenInfo.reqSubject
				handleInfo.startTime = 0
				handleInfo.hopeTime = 0
				handleInfo.reqDes = this.childrenInfo.reqDes
				handleInfo.isEdit = this.isEdit;
				console.log("aaaa-------->", this.ifedit, this.isEdit == 1)
				handleInfo.isChangeContent = 0;
				if (!this.ifedit) {
					handleInfo.isChangeContent = 1;
				}
				if (this.isEdit == 1) {
					handleInfo.content = this.getInfo()
				}
			},
			//处理页面获取下一步处理人需要的参数
			getHandleUserParams(opOptions) {
				var param = {}
				if (opOptions != "") {
					param.vari = opOptions
				}
				return param
			},
		},
		props: {
			isEdit: {},
			ifedit: {
				type: Boolean,
				default: false,
			},
			reqId: {
				default: null
			},
			draftsId: {
				default: null
			},
			filesList: {},
			processInfo: {}
		},
	}
</script>
